<?php

require_once("/home/geeka813/config/smarty.php");
require_once("/home/geeka813/logger/KLogger.php");

//define('INCLUDE_CHECK',true);

// Those two files can be included only if INCLUDE_CHECK is defined

session_name('tzLogin');
// Starting the session

session_set_cookie_params(2*7*24*60*60);
// Making the cookie live for 2 weeks

session_start();

$smarty = new Smarty();
$smarty->template_dir = $publicHtml . '/smarty_templates';
$smarty->compile_dir = $publicHtml . '/templates_c';
$smarty->cache_dir = $publicHtml . '/public_cache';
$smarty->config_dir = $publicHtml . '/configs';

$pdo = new PDO('mysql:host=localhost;dbname=geeka813_main', 'geeka813_neil', 'test1234');

$log = new KLogger ( "log.txt" , KLogger::INFO );
$log->LogInfo("At top of login.php, parameters = " . print_r($_REQUEST, TRUE));
	 
if($_SESSION['id'] && !isset($_COOKIE['ncRemember']) && !$_SESSION['rememberMe'])
{
	// If you are logged in, but you don't have the tzRemember cookie (browser restart)
	// and you have not checked the rememberMe checkbox:

        $log->LogInfo("Remembered session being cleaned");

	$_SESSION = array();
	session_destroy();

	// Destroy the session
}

if($_SESSION['id'])
{
   $log->LogInfo("User logged in");
   $loggedIn = true;
}
else
{
   $loggedIn = false;
}

if(isset($_GET['logoff']))
{
        $log->LogInfo("Logoff - Remembered session being cleaned");
	$_SESSION = array();
	session_destroy();
}

class User {
  public $user;
  public $id;
  public function full_name()
  {
    return $this->first_name . ' ' . $this->last_name;
  }
}

?>